﻿using Mono.Data.Sqlite;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class LoginMgr : MonoBehaviour {
    public InputField m_InputField;
	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		
	}
    public void OnClcikLogin() {
        if (m_InputField.text.Length <= 0) {
            return;
        }

        string cmd = "select Auth from USER_TABLE WHERE ID = '" + m_InputField.text+"'";
        SqliteDataReader reader = SQLManager.s_Instance.ExecuteSQLCommand(cmd);
        if (reader != null) {
            DataTable dataTable = new DataTable();
            dataTable.Load(reader);
            if (dataTable.Rows.Count > 0) {
                int auth = (int)dataTable.Rows[0]["Auth"];
                PlayerPrefs.SetInt("Auth", auth);
            } else {
                PlayerPrefs.SetInt("Auth", 0);
            }
        }
        PlayerPrefs.SetString("EditorName", m_InputField.text);
        SceneManager.LoadScene("Scene");
    }
}
